/**
 * 
 */
package co.fitstart.coach.dao;

import java.util.Date;
import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.coach.CoachRestCalendar;
import co.fitstart.entity.coach.CoachRestType;
import co.fitstart.entity.principal.Principal;

/**
 * @author downpour
 *
 */
@Dynamic("hibernate")
public interface RestCalendarDao {

    // TODO merge original coachRestCalendarService hql and coachRestCalendarDaoSupport here
    
    /**
     * 
     * @param principal
     * @param day
     * @param hour
     * @return
     */
    @Query("FROM CoachRestCalendar WHERE disabled = false AND coach = :coach AND restDate = :day AND restHour in (:hours)")
    public List<CoachRestCalendar> listCoachRestCalendar(@Variable("coach") Principal principal, @Variable("day") Date day, @Variable("hours") List<String> hours);
    
    /**
     * 
     * @param principal
     * @param day
     * @param hour
     * @param type
     * @return
     */
    @Query("FROM CoachRestCalendar WHERE disabled = false AND coach = :coach AND restDate = :day AND restHour in (:hours) AND coachRestType != :type")
    public List<CoachRestCalendar> listCoachRestCalendar(@Variable("coach") Principal principal, @Variable("day") Date day, @Variable("hours") List<String> hours, @Variable("type") CoachRestType type);
    
    
    /**
     * 
     * @param principal
     * @param day
     * @param hour
     * @param type
     * @return
     */
    @Query("FROM CoachRestCalendar WHERE disabled = false AND coach = :coach AND restDate = :day AND restHour in (:hours) AND coachRestType = :type")
    public List<CoachRestCalendar> getCoachRestCalendar(@Variable("coach") Principal principal, @Variable("day") Date day, @Variable("hours") List<String> hours, @Variable("type") CoachRestType type);
    
    /**
     * 
     * @param principal
     * @param day
     * @param hour
     * @param type
     * @return
     */
    @Query("FROM CoachRestCalendar WHERE disabled = false AND coach = :coach AND restDate = :day AND restHour = :hour AND coachRestType = :type")
    public List<CoachRestCalendar> listCoachRestCalendar(@Variable("coach") Principal principal, @Variable("day") Date day, @Variable("hour") String hour, @Variable("type") CoachRestType type);
}
